<%@page import="com.netistate.pojo.Project"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.netistate.pojo.Product"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>project</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/default.css" />
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/jquery-min.js"></script> 
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/common.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/js/table.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/msgbox/msgbox.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/jsp/demo/product.js"></script>
    <script type="text/javascript"  src="${pageContext.request.contextPath}/plugin/calendar/Calendar.js"></script>
    <style type="text/css">
		.overTd {table-layout:fixed}
		.overTd td{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:0px}
    </style>
  	</head>
  	<body>
    
	<div id="xtab">
		<a id="rightDiv0_tab" href="#" class='homelink ' onclick="transition()"><span style="cursor:pointer;">Demo页面</span></a>
		<a id="rightDiv1_tab" href="#" class='homelink curren' onclick=""><span style="cursor: pointer;">产品页面</span></a>
	</div>
	<div class="toolbar">
   		<span style="color:red">当前位置：查看产品信息</span>
	    <a href="#" class='buttonlink txbtip' title='添加机器' onclick="add()"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus.png'/>添加机器</a>  
	    <a href="#" id="queryProjectButton" class='buttonlink txbtip' onclick="notHiddenDiv()" title='机器查询'><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/plus.png'/>机器查询</a> 
	   	<%-- <a href="#" class='buttonlink txbtip' title='查看Demo机状态' style='float:right;' onclick="transition()"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/switch_back.png'/>切换到查看Demo机界面</a> --%>
	</div>
	
	<div id="productQuery" name="productQuery" class="toolbar" style="display:block;overflow:hidden;">
		    <form id="queryProductByCondition" name="queryProductByCondition" action="queryProductByCondition.action" method="post">
		        <table>
		           <tr>
		           		<td class="td_title" title="产品型号"><img alt="" src="${pageContext.request.contextPath}/images/common/search.png">产品型号：</td>
		           		<td class="td_title">
		                    <select id="product" name="productNo" style="width:100px;">
								<option value="所有">所有</option>
								<%  List<Product> productList = (List<Product>)request.getSession().getAttribute("productList");
									String queryProductNo = (String)request.getAttribute("queryProductNo");
									for(Product pro : productList){
									if(pro.getProduct().equals(queryProductNo)){%>
									<option title="<%=queryProductNo %>" selected value="<%=queryProductNo %>"><%=queryProductNo %></option>
								<%	} else { %>
								 	<option title="<%=pro.getProduct() %>" value="<%=pro.getProduct() %>"><%=pro.getProduct() %></option>
								 <% }}%>
		                    </select>
		                </td>
		                
		                <%-- <td class="td_title" title="产品关联项目">产品型号：</td>
		                <td class="td_title">
		                    <select id="project" name="project" style="width:100px;">
								<option value="所有">所有</option>
								<%  List<Project> projectList = (List<Project>)request.getSession().getAttribute("projectList");
									for(Project p : projectList){ %>
								 	<option title="<%=p.getProjectName() %>" value="<%=p.getId() %>"><%=p.getProjectName() %></option>
								 <% }%>
		                    </select>
		                </td> --%>
			            <td><input type="submit" value="查询" title="查询" /></td>
		           </tr>
		        </table>
		    </form>
		</div>
		
		<div id="rcon_onepage" style="width:100%; height:90%;overflow-y:scroll; border:1px solid;">
			<table id="dArticleList" width="100%" border="0" cellpadding="0" cellspacing="1"class="resizable overTd">
				<thead>
				<tr class="fixHead">
					<td class="td1" style="cursor:pointer" width="8%">产品型号</td>
					<!-- <td class="td1" width="6%">产品原始版本	</td> -->
					<td class="td1" style="cursor:pointer" width="6%">产品更新版本	</td>
					<td class="td1" style="cursor:pointer" width="6%">出厂日期</td>
					<td class="td1" style="cursor:pointer" width="6%">License截止日期</td>
					<td class="td1" style="cursor:pointer" width="6%">IP地址</td>
					<td class="td1" style="cursor:pointer" width="6%">子网掩码</td>
					<td class="td1" style="cursor:pointer" width="6%">网关</td>
					<td class="td1" style="cursor:pointer" width="6%">DNS</td>
					<td class="td1" style="cursor:pointer" width="4%">节点数</td>
					<td class="td1" style="cursor:pointer" width="10%">定制模块</td>
					<td class="td1" style="cursor:pointer" width="8%">硬件提供商</td>
					<td class="td1" style="cursor:pointer" width="9%">硬件配置</td>					
					<!-- <td class="td1" width="14%">工作内容</td> -->
					<td class="td1" style="cursor:pointer" width="10%">工作记录</td>
					<td class="td1" colspan="2">操作</td>					
				</tr>
                </thead>
                <tbody>
                <%
                	List<Product> list = new ArrayList<Product>();
					List<Product> plist = (List<Product>)request.getAttribute("pdList");
					if(plist == null){
						list = (List<Product>)request.getSession().getAttribute("productList");
					}else{
						list = plist;
					}
					 for(Product p : list){
					 	int id = p.getId();
				 %>
			       <tr onMouseOver= "this.bgColor   =   '#cccccc '; "   onMouseOut= "this.bgColor   =   '#FFFFFF'; " >  
				       <td title="<%=p.getProduct() %>" align="center" class="td2 txbtip" ><%=p.getProduct() %>&nbsp;</td>
				       <%-- <td title="<%=p.getPreVersion() %>" align="center" class="td2 txbtip" ><%=p.getPreVersion() %></td> --%>
					   <td title="<%=p.getPostVersion() %>" align="center" class="td2 txbtip" ><%=p.getPostVersion()%>&nbsp;</td>
				       <td title="<%=p.getOutDate() %>" align="center" class="td2 txbtip" ><%=p.getOutDate()%>&nbsp;</td>
				       <td title="<%=p.getLicenseTime() %>" align="center" class="td2 txbtip" ><%=p.getLicenseTime() %>&nbsp;</td>
				       <td title="<%=p.getIp() %>" align="center" class="td2 txbtip" ><%=p.getIp() %>&nbsp;</td>
				       <td title="<%=p.getMask() %>" align="center" class="td2 txbtip" ><%=p.getMask() %>&nbsp;</td>
				       <td title="<%=p.getGateway() %>" align="center" class="td2 txbtip" ><%=p.getGateway() %>&nbsp;</td>
				       <td title="<%=p.getDns() %>" align="center" class="td2 txbtip" ><%=p.getDns() %>&nbsp;</td>
				       <td title="<%=p.getNodes() %>" align="center" class="td2 txbtip" ><%=p.getNodes() %>&nbsp;</td>
				       <td title="<%=p.getModule() %>" align="center" class="td2 txbtip" ><%=p.getModule() %>&nbsp;</td>
				       <td title="<%=p.getHardwareSource() %>" align="center" class="td2 txbtip" ><%=p.getHardwareSource() %>&nbsp;</td>
				       <td style="cursor: hand;text-overflow:ellipsis;overflow:hidden;" title="<%=p.getProductConfig() %>" align="left" class="td2 txbtip" ><%=p.getProductConfig() %>&nbsp;</td>
				       <%-- <td title="<%=p.getWorkContent() %>" align="center" class="td2 txbtip" ><%=p.getWorkContent() %></td> --%>
				       <td title="<%=p.getWorkNote() %>" style="cursor: hand;text-overflow:ellipsis;overflow:hidden;" align="left" class="td2 txbtip" ><%=p.getWorkNote() %>&nbsp;</td> 
				       
				        <td align="center" class="td2 txbtip">
					     <a href="#" class='buttonlink txbtip' title='修改' onclick="edit(<%=id%>)"><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/edit.png'/></a>
				      </td>
		
				      <td align="center" class="td2 txbtip">
					      <a href="#" class='buttonlink txbtip' title='删除' onclick="del('<%=id%>','你确定要删除？')" ><img width='16' height='16' src='${pageContext.request.contextPath}/images/common/delete.png'/></a>
				      </td>
				       <%} %>
                	</tr>
                </tbody>

		</table>
		</div>
		
	<script type="text/javascript" >
	
		
		//增加product时，模块的切换
	    function changeModuleInProduct(){
	    	var module = document.getElementById("module").value;
	    	var customModuleProduct = document.getElementById("customModuleProduct");
	    	
	    	if(module == "定制模块"){
	    		customModuleProduct.style.display = 'inline';
	    	}else{
	    		customModuleProduct.style.display = 'none';
	    	};
	    };
		
		
		//修改demo时，模块的切换
	    function changeEditModuleInProduct(){
	    	var module = document.getElementById("editModuleProduct").value;
	    	var showEditModuleProduct = document.getElementById("showEditModuleProduct");
	    	if(module == "定制模块"){
	    		showEditModuleProduct.style.display = 'inline';
	    	}else{
	    		showEditModuleProduct.style.display = 'none';
	    	};
	    };
	
		//添加产品
		function add(){
	    	PigossMsg.show("${pageContext.request.contextPath}/jsp/demo/addProduct.jsp","添加机器",480,580,"AddProduct.saveConfig()");
		}
		
		//修改产品
		function edit(id){
			AjaxUtil.request({
				url : 'edit_product.action',
				params : {id:id},
				success : function(responseText){
		         PigossMsg.show("${pageContext.request.contextPath}/jsp/demo/editProduct.jsp?id="+id,"修改产品信息",480,580,"EditProduct.editProduct()");
				},
				failure : function(){
					 PigossMsg.alert("编辑失败!");
					}
				});			
		}
		
		//删除产品
		function del(id,msg){
			this.msg = msg;
	        PigossMsg.confirm(this.msg,null,function yesHandler(){EditProduct.del(id)},function noHandler(){});			
		}
		
		//切换到Demo机界面
		function transition(){
			AjaxUtil.request({
				url : "findAllDemo.action",
				params : {},
				success : function(responseText){
	   				window.parent.document.getElementById("mainFrame").src="${pageContext.request.contextPath}/jsp/demo/demo.jsp";
				}, 
				failure : function(){
					//PigossMsg.alert("添加失败!");
				}
			});
		}
	   
	    //隐藏查询工具栏
		function notHiddenDiv(){
	        var idDiv = document.getElementById('productQuery');
	        if(idDiv.style.display=='none'){
	            idDiv.style.display='block'; 
	        }else{
	           idDiv.style.display='none'; 
	        }
	    }
	    
	    initTableWidget('dArticleList',Array('S','S',"S",'S','S','S','S','S','S',false));
	  
	</script>
       
  </body>
</html>
